-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/ensure change output #152
base: master
Are you sure you want to change the base?
Conversation
7b3d4eb
to
9f6bc31
Compare
dlc-manager/src/utils.rs
Outdated
// We need to have a change output, if we didn't on first try, we request an amount which | ||
// includes minimum value for the change output as well as the fee for it. | ||
if total_value < appr_required_amount + min_change_value + inputs_fee + change_fee { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think the implementer of get_utxos_for_amount
should ever run into this? Isn't that just a bug in their implementation of the trait method?
I see the motivation, but I think this is a bit surprising. We can work on making the API easier to use and understand, but I think we shouldn't have to fix their mistakes by trying again with a slightly bigger amount here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So your proposal is just to error if there is not enough for change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's okay, yeah. I know we have dealt with stuff like this, but I can't really blame rust-dlc
if the API is clear and working as intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to return an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I'm still pondering on this. Wouldn't it be easier to just request an amount that includes a change output + minimum spendable amount for it from the beginning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's reasonable too and it seems simpler than what we are currently doing. I remember thinking that it might be a good idea to give more control to consumers of this API, but I can't figure out why now.
3c46ce4
to
29233b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Cool @Tibo-lg Can you remind me what problem this was fixing again? It's been a while since I looked at this code, but I do remember we had some trouble with it |
29233b4
to
97af684
Compare
97af684
to
fe3346b
Compare
@sosaucily I finally went with a version that handles the issue within the library. If you have time to take a look let me know.